#!/usr/bin/perl -w   # useful for syntax highlighting.
package clreqd_modules;

use strict;
use cldb;
use Config;
use Sys::Hostname;

sub complete_start_app {
my %ARGS=@_;

	local $SIG{CHLD}='DEFAULT';
	my $h=hostname;
	my $app=$ARGS{APP};

	my $cmd="$::ENV{TRUECL_CODE}/bin/lha_startapp --application $app --force --verbose --node $h";
	my $logfile="$::ENV{TRUECL_LOG}/startapp-$app.log";
	if(exists($ARGS{OK}) && length($ARGS{OK})) {
		$cmd.=" --livenodes $ARGS{OK}";
	}
	$cmd.=" >>$logfile 2>&1";

	# So the commmand now has been constructed, so run it as a child process...

	my $pid=fork();
	if(!defined($pid)) {
		return "ERROR Process fork failed - application not started.";
	}
	if($pid) {
		return "OK $pid";
	}
	# We are a the child process so run the code and exit.

	system("$cmd");
	exit($?>>8);
}

1;
